package com.example.figurehecheng.controller.user;


import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.vo.RestaurantVO;
import com.example.figurehecheng.service.IRestaurantService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 餐厅表 前端控制器
 * </p>
 * @author author
 * @since 2025-03-04
 */
@RestController("userRestaurantController")
@RequestMapping("/user/restaurant")
@Slf4j
public class RestaurantController {
    @Autowired
    private IRestaurantService restaurantService;
    /**
     * 查询餐厅列表
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询餐厅列表")
    public Result<List<RestaurantVO>> getRestaurantList() {
        List<RestaurantVO> restaurantList = restaurantService.queryRestaurantList();
        log.info(restaurantList.toString());
        return Result.success(restaurantList);
    }
    /**
     * 根据餐厅名称查询餐厅
     * @return
     */
    @GetMapping("/searchByName")
    @ApiOperation("根据餐厅名称查询餐厅")
    public Result<List<RestaurantVO>> searchRestaurantByName(@RequestParam("name") String name ) {
        // 根据餐厅名称查询餐厅
        List<RestaurantVO> restaurantList = restaurantService.searchRestaurantByName(name);
        return Result.success(restaurantList);
    }

}
